﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Leo.Awesome.DictionaryManagement.Dtos;
using Leo.Awesome.DictionaryManagement.Services;
using Swashbuckle.AspNetCore.Annotations;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using static Leo.Awesome.DictionaryManagement.Permissions.DictionaryManagementPermissions;

namespace Leo.Awesome.DictionaryManagement.Controllers
{
    [Area(DictionaryServiceConsts.ModuleName)]
    [RemoteService(Name = DictionaryServiceConsts.RemoteServiceName)]
    [Route("api/[controller]")]
    [SwaggerTag("字典树形管理")]
    public class SectionManagementController : DictionaryManagementController, ISectionAppService
    {
        private readonly ISectionAppService SectionAppService;

        public SectionManagementController(ISectionAppService SectionAppService)
        {
            this.SectionAppService = SectionAppService;
        }


        [HttpPost("")]
        [SwaggerOperation(
          Summary = "创建",
          Description = "",
          OperationId = "",
          Tags = new[] { "SectionManagement" }
        )]
        public async Task<SectionGetOutPutDto> CreateAsync(SectionCreateUpdateInput input)
        {
            return await SectionAppService.CreateAsync(input);
        }

        [HttpPost("Delete/{id}")]
        [SwaggerOperation(
         Summary = "删除",
         Description = "",
         OperationId = "",
         Tags = new[] { "SectionManagement" }
        )]
        public async Task DeleteAsync(Guid id)
        {
            await SectionAppService.DeleteAsync(id);
        }

  
        [HttpGet("Get/{id}")]
        [SwaggerOperation(
         Summary = "查询",
         Description = "",
         OperationId = "",
         Tags = new[] { "SectionManagement" }
        )]
        public async Task<SectionGetOutPutDto> GetAsync(Guid id)
        {
            return await SectionAppService.GetAsync(id);
        }

        [HttpPost("GetList")]
        [SwaggerOperation(
             Summary = "分页查询列表",
             Description = "",
             OperationId = "",
             Tags = new[] { "SectionManagement" }
        )]
        public async Task<PagedResultDto<SectionGetListOutputDto>> GetListAsync(SectionGetListInput input)
        {
            return await SectionAppService.GetListAsync(input);
        }

        [HttpPost("getTree")]
        [SwaggerOperation(
            Summary = "获取树列表",
            Description = "",
            OperationId = "",
            Tags = new[] { "SectionManagement" }
        )]
        public async Task<List<SectionTreeOutput>> GetTree(SectionTreeInput input)
        {
            return await SectionAppService.GetTree(input);
        }

        [HttpPost("Query")]
        [SwaggerOperation(
          Summary = "查询列表",
          Description = "",
          OperationId = "",
          Tags = new[] { "SectionManagement" }
        )]
        public async Task<List<SectionGetListOutputDto>> Query(SectionGetListInput getListInput)
        {
            return await SectionAppService.Query(getListInput);
        }

        [HttpPost("QueryByPage")]
        [SwaggerOperation(
          Summary = "分页查询列表",
          Description = "",
          OperationId = "",
          Tags = new[] { "SectionManagement" }
        )]
        public async Task<SectionPagedResultDto> QueryByPage(SectionGetListPageInput getListPageInput)
        {
            return await SectionAppService.QueryByPage(getListPageInput);
        }

        [HttpPost("QueryCount")]
        [SwaggerOperation(
        Summary = "统计",
        Description = "",
        OperationId = "",
        Tags = new[] { "SectionManagement" }
        )]
        public async Task<long> QueryCount(SectionGetListInput getListInput)
        {
            return await SectionAppService.QueryCount(getListInput);
        }

        [HttpPost("Update/{id}")]
        [SwaggerOperation(
          Summary = "更新",
          Description = "",
          OperationId = "",
          Tags = new[] { "SectionManagement" }
        )]
        public async Task<SectionGetOutPutDto> UpdateAsync(Guid id, SectionCreateUpdateInput input)
        {
            return await SectionAppService.UpdateAsync(id, input);
        }      
    }
}
